package com.classic.mafiacards;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;

public class MainActivity extends Activity {

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    public void onResume() {
        super.onResume();
        OptionsReader.updateLanguage(this);
        setContentView(R.layout.activity_main);

        ImageView clicker = (ImageView) findViewById(R.id.invisiableButton);
        clicker.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this, CardsActivity.class));
            }
        });

        CardsActivity.players.clear();
    }

    public boolean onPrepareOptionsMenu(Menu menu) {
        OptionsReader.updateLanguage(this);
        menu.clear();
        getMenuInflater().inflate(R.menu.menu_open_settings, menu);
        getMenuInflater().inflate(R.menu.menu_show_timer, menu);
        return true;
    }

    public void onBackPressed() {
        android.os.Process.killProcess(android.os.Process.myPid());
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_show_timer:
                startActivity(new Intent(MainActivity.this, TimerActivity.class));
                return true;
            case R.id.action_open_settings:
                startActivity(new Intent(MainActivity.this, OptionsActivity.class));
                return true;
            default:
                return super.onOptionsItemSelected(item);

        }
    }

}
